<?php 

$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);

$dialog = $this->widget('ext.ecolumns.EColumnsDialog', array(
   'options'=>array(
		'title' => 'Настройки',
		'autoOpen' => false,
		'show' =>  'fade',
		'hide' =>  'fade',
	),
   'htmlOptions' => array('style' => 'display: none'), //disable flush of dialog content
   'ecolumns' => array(
		'gridId' => 'src-grid', //id of related grid
		'storage' => 'session',  //where to store settings: 'db', 'session', 'cookie'
		'fixedLeft' => array('CCheckBoxColumn'), //fix checkbox to the left side 		
		'model' => $model->search(), //model is used to get attribute labels
		'columns' => array(
			array(
				'header'=>'',		
				'class'=>'bootstrap.widgets.TbButtonColumn',
				'template'=>'{delete} {update}',
				'htmlOptions' => array('style'=>'width:50px'),
			),		
			array
			(
				'class' => 'editable.EditableColumn',				
				'name'=>'site',
				'header'=>'Сайт',				
				'value' => array($this, 'checkResultSite'),
				'filter' => array(''=>'Фильтр','re'=>'Время электроники','elcom'=>'ЭЛ компоненты','light'=>'Светотехника','jer'=>'ЖЭР'), 
				'htmlOptions'=>array('style'=>'text-align: center'),
				'editable' => array(
					'type'     => 'select',
					'url'      => $this->createUrl('src/updatee'),
					'placement'  => 'right',						
					'source'   => array('default'=>'Выбрать','re'=>'Время электроники','elcom'=>'ЭЛ компоненты','light'=>'Светотехника','jer'=>'ЖЭР'),				
				),
			),
			array
			(
				'class' => 'editable.EditableColumn',				
				'name'=>'src',
				'header'=>'Материал',					
				'value'=>'$data->src',
				'htmlOptions'=>array('style'=>'text-align: center'),
				'editable' => array(
					'url'        => $this->createUrl('src/updatee'),
					'placement'  => 'right',
					'inputclass' => 'span3',
				),						
			),	
			array
			(
				'class' => 'editable.EditableColumn',				
				'name'=>'active',
				'header'=>'Состояние',					
				'value'=>'$data->active',
				'value' => array($this, 'checkResultActive'),
				'filter' => array(''=>'Фильтр','0'=>'Выкл.','1'=>'Вкл.'), 
				'htmlOptions'=>array('style'=>'text-align: center'),
				'editable' => array(
					'type'       => 'select',
					'url'        => $this->createUrl('src/updatee'),
					'placement'  => 'right',
					'source'     => array(''=>'Выбрать','0'=>'Выкл.','1'=>'Вкл.'),
				),						
			),	
			array
			(
				'class' => 'editable.EditableColumn',				
				'name'=>'d_start',
				'header'=>'Дата начала',					
				'value'=>'$data->d_start',
				'htmlOptions'=>array('style'=>'text-align: center'),
				'editable' => array(
					'type'       => 'date',
					'viewformat' => 'dd.mm.yyyy',				
					'url'        => $this->createUrl('src/updatee'),
					'placement'  => 'right',
				),						
			),					
			array
			(
				'class' => 'editable.EditableColumn',				
				'name'=>'d_end',
				'header'=>'Дата окончания',					
				'value'=>'$data->d_start',
				'htmlOptions'=>array('style'=>'text-align: center'),
				'editable' => array(
					'type'       => 'date',
					'viewformat' => 'dd.mm.yyyy',				
					'url'        => $this->createUrl('src/updatee'),
					'placement'  => 'right',
				),						
			),	
			array
			(
				'class' => 'editable.EditableColumn',				
				'name'=>'manager',
				'header'=>'Менеджер',				
				'value' => array($this, 'checkResultManager'),
				'filter' => array(''=>'Фильтр','popova'=>'Попова','denisov'=>'Денисов','jivova'=>'Живова'), 
				'htmlOptions'=>array('style'=>'text-align: center'),
				'editable' => array(
					'type'     => 'select',
					'url'      => $this->createUrl('src/updatee'),
					'placement'  => 'right',						
					'source'   => array('popova'=>'Попова','denisov'=>'Денисов','jivova'=>'Живова'),				
				),
			),			
			array
			(					
				'name'=>'d_cr',
				'header'=>'Дата создания',					
				'value'=>'$data->d_cr',
				'htmlOptions'=>array('style'=>'text-align:center;'),					
			),				
		),
	),
));
						
if(Yii::app()->user->hasFlash('double')) { echo '<div style="margin:5px;color:red;">'.Yii::app()->user->getFlash('double').'</div>'; }
						
$this->widget('bootstrap.widgets.TbButton', array('label'=>'Добавить запись','size'=>'normal','url'=>array('create')));
echo "&nbsp;".$dialog->link();
echo "&nbsp;".CHtml::dropDownList('pageSize',$pageSize,array(10=>10,20=>20,50=>50,100=>100),array('onchange'=>"$.fn.updateGrid($(this).val())"))."";

$this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'src-grid',
    'itemsCssClass'=>'default',
	'type'=>'striped bordered condensed',
    'dataProvider'=>$model->search(),
	'columns' => $dialog->columns(),
	'template' => "{summary}\n{items}\n{pager}",
	'filter'=>$model,
));	
?>
